<template>
	<view>
		<view style="background-color: white;">
			<view style="background-color: #eeeeee;height: 60px;margin: 10px;display: flex;align-items: center;padding: 0 10px;border-radius: 5px;">
				<u-avatar @click="tel(userinfo.tel)" :src="userinfo.avatar" size="45"></u-avatar>
				<view @click="tel(userinfo.tel)" style="margin-left: 10px;">
					<p style="display: flex;align-items: center;">{{userinfo.nickname}}<u-icon v-if="userinfo.vip>new Date().getTime()" name="/static/other/vip.png" style="margin-left: 3px;" size="18" /></p>
					<p style="font-size: 14px;color: #989898;">永久分享</p>
				</view>
				<view style="flex: 1;display: flex;justify-content: flex-end;">
					<button size="mini" type="primary" style="margin: 0;" @click="goapp">下载App</button>
				</view>
			</view>
			<!-- 图片类型 -->
			<view v-if="data.type=='img'||data.type=='video'">
				<p style="text-align: center;">{{data.title}}</p>
				<view v-if="data.type=='img'" style="padding: 10px;">
					<image @click="openImg([urls],0)" :src="urls" style="width: 100%;border-radius: 5px;" mode="widthFix"></image>
				</view>
				<video v-if="data.type=='video'" :src="urls" style="width: 100%;margin-top: 10px;"></video>
				<view v-if="data.content!=''&&data.content!=null" style="padding: 15px;background-color: white;">
					<view style="background-color: #fff6e4;color: #7b7458;padding: 7px;border-radius: 7px;font-size: 14px;">
						<rich-text selectable :nodes="data.content"></rich-text>
					</view>
				</view>
				<p style="font-size: 14px;text-align: right;line-height: 30px;margin-right: 10px;" @click="report(data._id,data.title)">举报</p>
			</view>
			<!-- 其他文件类型 -->
			<view v-if="data.type=='other'" style="text-align: center;padding-top: 20px;">
				<image :src="data.icon" style="width: 80px;height: 80px;border-radius: 10px;"></image>
				<p style="font-size: 16px;margin-top: 10px;">{{data.title}}</p>
				<view @click="down(data._id)" style="background-color: #33c4fd;color: white;padding: 12px;border-radius: 7px;font-size: 16px;margin:20px 100px 0 100px;">
					下载（{{data.size}}）
				</view>
				<p style="font-size: 14px;text-align: right;line-height: 30px;margin-right: 10px;" @click="report(data._id,data.title)">举报</p>
			</view>
		</view>
		<websitenav></websitenav>
	</view>
</template>

<script>
	const db = uniCloud.database();
		import ase from '@/common/ar-aes/ar-aes.js'
	export default {
	props: {
		data: {
			type: Object,
			default (data) {
				return {}
			}
		}
	},
		name: "moren",
		data() {
			return {
				urls:null,
				userinfo: {
					avatar: null,
					nickname: null,
					tel:null
				}
			};
		},
		methods: {
			goapp(){
				window.location.href='http://www.x2.ink'
			},
			tel(tel){
				if(this.userinfo.tel==null){
					return null
				}
				uni.showModal({
					title: '联系方式',
					content: tel
				});
			},
			report(id,title){
				uni.navigateTo({
					url: '../feedback/feedback?id='+id+'&type=file'
				});
			},
			down(id){
				this.$emit("down",{id:id})
			},
			async geturl(id){
				 const res=await db.collection("item").where({_id:id}).get()
				 this.urls=res.result.data[0].url
			},
			async getuserinfo(data) {
				const res=await db.collection("uni-id-users").where({_id:data.user_id}).field("nickname,avatar,tel,vip").get()
					this.userinfo=res.result.data[0]
					if(data.type=='img'){
					this.geturl(this.data._id)
					}else if(data.type=='video'){
						if(res.result.data[0].vip>new Date().getTime()){
								this.geturl(this.data._id)
						}else{
							uni.showModal({
								title: '提示',
								content: '发布者非会员用户，无法在线观看视频！'
							});
						}
					}
			}
		},
		mounted() {
		this.getuserinfo(this.data)
		}
	}
</script>

<style lang="less">
	body {
		background-color: white;
	}
</style>
